package com.ojoin.trade.t0loan_core.web.filter;

import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ojoin.trade.common.utils.CommonUtils;
import com.ojoin.trade.t0loan_core.web.monitor.ThreadTrace;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-8
 * Time: 下午3:11
 * To change this template use File | Settings | File Templates.
 */
public class MonitorFilter extends BaseFilter {


    public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {

        String remoteaddr=request.getRemoteAddr();
        String method=request.getMethod();
        String url=request.getRequestURI();
        boolean needMonitorThread = !CommonUtils.isEmpty(url)&&(url.contains("account")||url.contains("area")||url.contains("bank")||url.contains("card")||url.contains("merchantuser")||url.contains("t0loan")||url.contains("credit"));
		if(needMonitorThread){
			ThreadTrace.getInstance().startThreadMonitor( method, remoteaddr, url);
		}
		
        chain.doFilter(request, response);
        
        if(needMonitorThread){
        	ThreadTrace.getInstance().endMonitor();
        }
    }
    public void destroy() {

    }
}
